package org.argeproje.resim.property;

import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.views.properties.PropertyDescriptor;

public class FileSelectPropertyDescriptor extends PropertyDescriptor {

	public FileSelectPropertyDescriptor(Object id, String displayName) {
		super(id, displayName);
	}

	public CellEditor createPropertyEditor(Composite parent) {
        CellEditor editor = new FileSelectCellEditor(parent);
        //editor.setValidator(new CellFilePathValidator());   
         return editor;
	}
}

class FileSelectCellEditor extends DialogCellEditor
{
	public FileSelectCellEditor(Composite parent) {
        super(parent);
     }

	@Override
	protected Object openDialogBox(Control cellEditorWindow) {
		FileDialog fd = new FileDialog(cellEditorWindow.getShell(),SWT.OPEN);
		fd.setText("Select Image File");
        //fd.setFilterPath(".");
        String[] filterExt = { "*.jpg", "*.bmp", "*.*" };
        fd.setFilterExtensions(filterExt);
        return fd.open();
	}
	
}
